function showInput(obj) {
	$(obj).hide();
	$(obj).next("input").show();
}

function updateClass(id, opType, obj,type) {
	var value = $(obj).val();
	if ((opType == '1' || opType == '2' || opType == '4') && value == '') {
		alert("不能为空!");
		return;
	}
	if(opType == '2' && type =='POSITION2'){
		if(!checkNum(value)){
			alert("位置2的标签必须为数字");
			return ;
		}
	}
	var param = {
		"id" : id,
		"type" : opType,
		"value" : value
	}
	API.managementUpdateLabel(param, function(res) {
		if (res.code == '0') {
			window.location.reload();
		} else {
			alert(res.desc);
		}
	});
}

function deleteById(id) {
	var param = {
		"id" : id
	}
	API.managementDeleteLabel(param, function(res) {
		if (res.code == '0') {
			window.location.reload();
		} else {
			alert(res.desc);
		}
	});

}
function checkNum(obj) {
	var reg = /^[0-9]*$/;
	return reg.test(obj);

};
function addLabel(obj, type) {
	var labelName = $("#labelName").val();
	var label = $("#label").val();
	var englishLabel = $("#englishLabel").val();
	var rank = $("#rank").val();
	if (labelName == '' || label == '' || rank == '') {
		alter("标签名称,标签,rank必须填写");
		return;
	}
	if(type =='POSITION2'){
		if(!checkNum(label)){
			alert("位置2的标签必须为数字");
			return ;
		}
	}
	var param = {
		"labelName" : labelName,
		"label" : label,
		"rank" : rank,
		"englishLabel" : englishLabel,
		"type" : type
	}
	API.managementAddLabel(param, function(res) {
		if (res.code == '0') {
			window.location.reload();
		} else {
			alert(res.desc);
		}
	});

}